package com.flexcloudsdk.apiidentity;

import java.util.logging.Logger;
import com.google.appengine.api.appidentity.PublicCertificate;

public class CloudPublicCertificate {
	private PublicCertificate pc;
	private String sourceClass;
	private String sourceMethod;

	private static final Logger log = Logger.getLogger(CloudPublicCertificate.class.getName());

	public CloudPublicCertificate() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		sourceClass = CloudPublicCertificate.class.getName();
		log.info("CloudPublicCertificate has been created by BlazeDS");
	}

	public void createCertificate(String val, String val2) {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		pc = new PublicCertificate(val, val2);
	}

	public String getCertificateName() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		return pc.getCertificateName();
	}

	public String getX509CertificateInPermFormat() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		return pc.getX509CertificateInPemFormat();
	}

}
